<?php
class DB{
    static $obj=null;


    private  function __construct()
    {
        echo "mysql linked......";
    }
    static function getObj(){
        if(is_null(self::$obj)){
            self::$obj=new  self();
        }
        return self::$obj;
    }
    public  function  select(){
        echo "select data...";
    }
}
class  Printer{
    private  static $obj=null;

    private  function __construct()
    {
    }
    public static function getInstance()
    {
        if(is_null(self::$obj)){
            self::$obj =new  Printer();
        }
        return self::$obj;
    }
}

$p1=Printer::getInstance();
$p2=Printer::getInstance();
var_dump($p1);
var_dump($p2);
var_dump($p2==$p1);
?>